package com.mylhyl.zxing.scanner.common;

import com.google.zxing.Result;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser;
import ohos.agp.components.element.Element;
import ohos.agp.render.Canvas;
import ohos.app.Context;
import ohos.global.configuration.DeviceCapability;
import ohos.global.resource.solidxml.TypedAttribute;
import ohos.media.image.PixelMap;
import ohos.media.image.common.PixelFormat;

public final class Scanner {
    public static final int RESTART_PREVIEW = 0;
    public static final int DECODE = 5;

    public static ParsedResult parseResult(Result rawResult) {
        if (rawResult == null) return null;
        return ResultParser.parseResult(rawResult);
    }

    public static int dp2px(Context context, int dpValue) {
        int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI;
        return density * dpValue;
    }

    public static int sp2px(Context context, int spValue) {
        int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI;
        return density * spValue;
    }

    public static PixelMap drawableToBitmap(Element drawable) {
        return PixelMap.create(new int[0],null);
    }

    public static class color {
        public static final int VIEWFINDER_MASK = 0x60000000;
        public static final int RESULT_VIEW = 0xb0000000;
        public static final int VIEWFINDER_LASER = 0xff00ff00;
        public static final int POSSIBLE_RESULT_POINTS = 0xc0ffbd21;
        public static final int RESULT_POINTS = 0xc099cc00;
    }

    public static class Scan {

        public static final String RESULT = "SCAN_RESULT";
    }

    public static class ScanMode {

        public static final String PRODUCT_MODE = "PRODUCT_MODE";

        public static final String ONE_D_MODE = "ONE_D_MODE";

        public static final String QR_CODE_MODE = "QR_CODE";

        public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
    }
}
